package com.ruoyi.hualian.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hualian.domain.HlTimingPulley;
import com.ruoyi.hualian.service.IHlTimingPulleyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 同步轮Controller
 * 
 * @author hujian
 */
@RestController
@RequestMapping("/hualian/pulley")
public class HlTimingPulleyController extends BaseController
{
    @Autowired
    private IHlTimingPulleyService hlTimingPulleyService;

    /**
     * 查询同步轮列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:pulley:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlTimingPulley hlTimingPulley)
    {
        startPage();
        List<HlTimingPulley> list = hlTimingPulleyService.selectHlTimingPulleyList(hlTimingPulley);
        return getDataTable(list);
    }

    /**
     * 导出同步轮列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:pulley:export')")
    @Log(title = "同步轮", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlTimingPulley hlTimingPulley)
    {
        List<HlTimingPulley> list = hlTimingPulleyService.selectHlTimingPulleyList(hlTimingPulley);
        ExcelUtil<HlTimingPulley> util = new ExcelUtil<HlTimingPulley>(HlTimingPulley.class);
        util.exportExcel(response, list, "同步轮数据");
    }

    /**
     * 获取同步轮详细信息
     */
    @PreAuthorize("@ss.hasPermi('hualian:pulley:query')")
    @GetMapping(value = "/{tpId}")
    public AjaxResult getInfo(@PathVariable("tpId") Long tpId)
    {
        return success(hlTimingPulleyService.selectHlTimingPulleyByTpId(tpId));
    }

    /**
     * 新增同步轮
     */
    @PreAuthorize("@ss.hasPermi('hualian:pulley:add')")
    @Log(title = "同步轮", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlTimingPulley hlTimingPulley)
    {
        return toAjax(hlTimingPulleyService.insertHlTimingPulley(hlTimingPulley));
    }

    /**
     * 修改同步轮
     */
    @PreAuthorize("@ss.hasPermi('hualian:pulley:edit')")
    @Log(title = "同步轮", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlTimingPulley hlTimingPulley)
    {
        return toAjax(hlTimingPulleyService.updateHlTimingPulley(hlTimingPulley));
    }

    /**
     * 删除同步轮
     */
    @PreAuthorize("@ss.hasPermi('hualian:pulley:remove')")
    @Log(title = "同步轮", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tpIds}")
    public AjaxResult remove(@PathVariable Long[] tpIds)
    {
        return toAjax(hlTimingPulleyService.deleteHlTimingPulleyByTpIds(tpIds));
    }
}
